@import '~app/styles/base/init';

.markdown-editor {

  &.fullscreen {
    position: fixed;
    width: 100%;
    height: calc(100% - 45px - 2.8rem);
    top: $top-height;
    left: 0;
    z-index: 999999;
    background-color: rgba(0, 0, 0, 0.95);

    .editor-content {

      .editor {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;

        .CodeMirror,
        .CodeMirror-scroll {
          height: 100%;
          max-height: 100%;
        }
      }
    }
  }

  .editor-toolbar {
    display: flex;
    width: 100%;
    height: 2.8rem;
    justify-content: space-between;
    padding: .1em;

    ul {
      display: block;
      margin: 0;
      padding: 0;
      flex-direction: column;

      li {
        cursor: pointer;
        height: 2.65rem;
        padding: 0 1rem;
        line-height: 2.8rem;
        text-align: center;
        display: block;
        float: left;

        > i {
          font-size: 1.5em;
        }

        &:hover {
          background-color: $sidebar;
        }
      }
    }
  }

  .editor-content {
    position: relative;
    overflow: hidden;
    height: 100%;
    width: 100%;

    &.preview-full {

      .marked {
        left: 0%;
      }
    }

    &.preview-both {
      .editor {
        width: 50%;
      }

      .marked {
        left: 50%;
        width: 50%;
      }
    }

    .editor {
      width: 100%;
      transition: left 0.1s ease;

      .CodeMirror {
        height: auto;
        min-height: 20rem;
        max-height: 46rem;
      }
      .CodeMirror-scroll {
        height: auto;
        min-height: 20rem;
        max-height: 46rem;
      }
      .CodeMirror-code {
        line-height: 1.6em;
        font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
        height: auto;
      }
    }

    .marked {
      left: 100%;
      width: 100%;
      height: 100%;
      position: absolute;
      top: 0;
      overflow: auto;
      z-index: 99;
      color: #333;
      padding: 2em;
      background-color: $default;
      transition: left 0.1s ease;

      a {
        color: $primary;
        font-weight: bold;
        margin: 0 .1em;

        &:hover {
          text-decoration: underline!important;
        }
      }

      img {
        max-width: 80%;
        margin: 0 auto;
        display: block;
        text-align: center;
        border-radius: 2px;
        border: .7rem solid rgba(197, 197, 197, 0.4);
      }

      code {
        padding: .3em .5em;
        margin: 0 .5em;
        border-radius: 2px;
        background-color: rgba(197, 197, 197, 0.4);
      }

      p {
        line-height: 2.2em;
        text-indent: 2em;
        margin-bottom: 1em;
      }

      h1,
      h2,
      h3,
      h4,
      h5,
      h6 {
        margin: 1.5rem 0;
        padding-left: 0;
        line-height: 1.8em;
        font-weight: 700;
        text-indent: 0;
      }

      blockquote {
        margin: 1.2em 0;
        text-indent: 0em;
        background-color: rgba(197, 197, 197, 0.4);
        border-left: .5em solid #aaa;
        padding: .5em 1em;
        padding-left: 1.5em;

        p {
          text-indent: 0em;

          &:last-child {
            margin-bottom: 0;
          }
        }
      }

      ul {
        list-style-type: square;
      }

      ul, ol {

        > li {
          line-height: 1.8em;
          padding: .5em 1em;

          &:hover {
            background-color: rgba(230, 230, 230, 0.7);
          }

          > ul {

            &:last-child {
              margin-bottom: 0;
            }
          }
        }
      }

      pre {
        margin-bottom: 1em;

        > code {
          margin: 0;
          padding: 1em;
          line-height: 1.6em;
          background-color: rgba(0, 0, 0, 0.8);
          position: relative;
          display: block;
          color: rgba(255, 255, 255, 0.87);
        }
      }
    }
  }
}